import java.util.Scanner;

public class zuiduodeshu {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int[] b = new int[a];
        int[] c = new int[a];
        int e = 1;
        for (int i = 0; i < a; i++) {
            b[i] = in.nextInt();
        }
        for (int i = 0; i < b.length; i++) {
            for (int j = 0; j < b.length - 1; j++) {
                if (b[i] == b[j]) {
                    c[i]++;
                }
                for (int k = 0; k <b.length-1 ; k++) {
                    if(c[k]>c[k+1]){
                        int d=c[k];
                        c[k]=c[k+1];
                        c[k+1]=d;
                        e=b[j];
                    }
                }
            }
        }
        System.out.println(e);
    }
}